<%= simple_form_for @invoice do |f| %>

<% if @invoice.errors.any? %>
<div id="error_explanation">
	<h2><%= pluralize(@invoice.errors.count, "error") %> prohibited this invoice from being saved:</h2>

	<ul>
		<% @invoice.errors.full_messages.each do |msg| %>
		<li>
			<%= msg %>
		</li>
		<% end %>
	</ul>
</div>
<% end %>

<%= f.association :customer, label_method: :company  %>
<%= f.input :user_id, as: :hidden, :input_html => { :value => current_user.id }  %>

<p>
	<%= link_to_add_association 'Add Item', f, :invoice_items, :data => { "association-insertion-node" => 'tbody', "association-insertion-metho" => 'after' } %>
</p>
<table class="table table-striped table-bordered" >
	<thead>
		<tr>
			<th> Item</th>
			<th> Size </th>
			<th> Qty </th>
			<th></th>
		</tr>
	</thead>
	<tbody>
		<%= f.simple_fields_for :invoice_items  do |task| %>
			<%= render 'invoice_item_fields', :f => task %>
		<% end %>
	</tbody>
</table>

<p>
	<%= f.button :submit, :class => "btn btn-default"  %>
</p>

<% end %>

